/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dbTool;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Home
 */
public class myConnection {
    public Connection connect(){
       Connection con = null;
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con = DriverManager.getConnection("jdbc:odbc:showroom", "sa", "admin@123");   
        }catch (SQLException ex) {
            Logger.getLogger(myConnection.class.getName()).log(Level.SEVERE, null, ex);
            ex.printStackTrace();
        }
        catch (ClassNotFoundException ex) {
            Logger.getLogger(myConnection.class.getName()).log(Level.SEVERE, null, ex);
            
        }
           return con;
   }
    
    public static void main(String[] args) {
        try {
            String sqlSelect = "select * from staff where staffAcc=? and staffPass=?";
            myConnection mc = new myConnection();
            Connection conn = mc.connect();
            ResultSet rs = null;
            PreparedStatement pstmt = conn.prepareStatement(sqlSelect);
            pstmt.setString(1, "admin");
            pstmt.setString(2, "123456");
            rs = pstmt.executeQuery();
            if(rs.next()){
                System.out.println("OK");
            }
            else System.out.println("FALSE");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
